################################################################################
#
#                       美国民粹主义外交政策的民意基础                       
#
#                            付 舒    2025年10月     
#
################################################################################


#####（四）基于匹配的因果推断  ######

library(Matching)

ccga2022_popu_matching <- ccga2022_popu %>%
  dplyr::select(
         # DVs
         isolate, cost, no_involve, part_io, threat_within, alliance, nato,
         tariff, econ_super, econ_aid, sanction, econ_not_priority, priority_econ_gain,
         anti_hr_demo, demo_not_best, threat_demo, anti_dei,
         # treatment
         poli_pred_lm, econ_pred_lm, cult_pred_lm, 
         # covariates
         cv_vote2020trump, cv_ideology, cv_party, 
         cv_religion_catho, cv_religion_chris, 
         cv_houseowner, cv_female, cv_age,cv_marital_mar, 
         cv_race_white, cv_race_black, cv_race_latin, 
         cv_education, cv_income) %>%
  na.omit() %>%
  mutate(poli_dummy = ifelse(poli_pred_lm >= mean(ccga2022_popu$poli_pred_lm, na.rm = T), 1, 0),
         econ_dummy = ifelse(econ_pred_lm >= mean(ccga2022_popu$econ_pred_lm, na.rm = T), 1, 0),
         cult_dummy = ifelse(cult_pred_lm >= mean(ccga2022_popu$cult_pred_lm, na.rm = T), 1, 0)) 


# Political
model_p1 <- Match(Y = ccga2022_popu_matching$isolate,
              Tr = ccga2022_popu_matching$poli_dummy,
              X = ccga2022_popu_matching[, c("econ_pred_lm", "cult_pred_lm")],
              caliper = 0.2, Weight = 2,  
              estimand = "ATT")
summary(model_p1)

model_p2 <- Match(Y = ccga2022_popu_matching$cost,
              Tr = ccga2022_popu_matching$poli_dummy,
              X = ccga2022_popu_matching[, c("econ_pred_lm", "cult_pred_lm")],
              caliper = 0.2, Weight = 2,   
              estimand = "ATT")
summary(model_p2)

model_p3 <- Match(Y = ccga2022_popu_matching$alliance,
              Tr = ccga2022_popu_matching$poli_dummy,
              X = ccga2022_popu_matching[, c("econ_pred_lm", "cult_pred_lm")],
              caliper = 0.2, Weight = 2,     
              estimand = "ATT")
summary(model_p3)

model_p4 <- Match(Y = ccga2022_popu_matching$part_io,
              Tr = ccga2022_popu_matching$poli_dummy,
              X = ccga2022_popu_matching[, c("econ_pred_lm", "cult_pred_lm")],
              caliper = 0.2, Weight = 2,  
              estimand = "ATT")
summary(model_p4)

model_p5 <- Match(Y = ccga2022_popu_matching$nato,
              Tr = ccga2022_popu_matching$poli_dummy,
              X = ccga2022_popu_matching[, c("econ_pred_lm", "cult_pred_lm")],
              caliper = 0.2, Weight = 2,  
              estimand = "ATT")
summary(model_p5)

## check balance
MatchBalance(poli_dummy ~ econ_pred_lm + cult_pred_lm,
             data = ccga2022_popu_matching,
             match.out = model_p1,
             ks = TRUE,
             nboots = 500)




# Economic
model_e1 <- Match(Y = ccga2022_popu_matching$tariff,
              Tr = ccga2022_popu_matching$econ_dummy,
              X = ccga2022_popu_matching[, c("poli_pred_lm", "cult_pred_lm")],
              caliper = 0.2, Weight = 2,  
              estimand = "ATT")
summary(model_e1)

model_e2 <- Match(Y = ccga2022_popu_matching$econ_not_priority,
              Tr = ccga2022_popu_matching$econ_dummy,
              X = ccga2022_popu_matching[, c("poli_pred_lm", "cult_pred_lm")],
              caliper = 0.2, Weight = 2,  
              estimand = "ATT")
summary(model_e2)

MatchBalance(econ_dummy ~ poli_pred_lm + cult_pred_lm,
             data = ccga2022_popu_matching,
             match.out = model_e1,
             ks = TRUE,
             nboots = 500)


# Cultural
model_c1 <- Match(Y = ccga2022_popu_matching$anti_hr_demo,
              Tr = ccga2022_popu_matching$cult_dummy,
              X = ccga2022_popu_matching[, c("poli_pred_lm", "econ_pred_lm")],
              caliper = 0.2, Weight = 2,  
              estimand = "ATT")
summary(model_c1)

model_c2 <- Match(Y = ccga2022_popu_matching$demo_not_best,
              Tr = ccga2022_popu_matching$cult_dummy,
              X = ccga2022_popu_matching[, c("poli_pred_lm", "econ_pred_lm")],
              caliper = 0.2, Weight = 2,  
              estimand = "ATT")
summary(model_c2)

model_c3 <- Match(Y = ccga2022_popu_matching$threat_demo,
              Tr = ccga2022_popu_matching$cult_dummy,
              X = ccga2022_popu_matching[, c("poli_pred_lm", "econ_pred_lm")],
              caliper = 0.2, Weight = 2,  
              estimand = "ATT")
summary(model_c3)

model_c4 <- Match(Y = ccga2022_popu_matching$anti_dei,
              Tr = ccga2022_popu_matching$cult_dummy,
              X = ccga2022_popu_matching[, c("poli_pred_lm", "econ_pred_lm")],
              caliper = 0.2, Weight = 2,  
              estimand = "ATT")
summary(model_c4)

MatchBalance(cult_dummy ~ poli_pred_lm + econ_pred_lm,
             data = ccga2022_popu_matching,
             match.out = model_c1, Weight = 2,  
             ks = TRUE,
             nboots = 500)



